package demo2;

/**
 * 泛型
 * Object 可以接收 普通类型
 * 在编译时 <T> 会擦除成object
 */
public class Text {
    public static void main(String[] args) {
        MyArray<Integer> myArray1 = new MyArray<>();
        myArray1.setObject(0,0);
        myArray1.setObject(1,1);
        myArray1.setObject(2,2);
        myArray1.setObject(3,3);
        myArray1.setObject(4,4);
        for(int i = 0;i <myArray1.object.length;i++) {
            System.out.print(myArray1.getObject(i) + " ");
        }
        System.out.println("===================");
        MyArray<String> myArray2 = new MyArray<>();
        myArray2.setObject(0,"a");
        myArray2.setObject(1,"b");
        myArray2.setObject(2,"c");
        myArray2.setObject(3,"d");
        myArray2.setObject(4,"e");
        myArray2.setObject(5,"f");
        for(int i = 0; i< myArray2.object.length;i++) {
            System.out.print(myArray2.getObject(i) + " ");
        }
    }
}
